from .generic import GenericAPIView
from .serializers import BaseSerializer

# 定义视图 继承类视图


class BookView(GenericAPIView):

    def post(self, request):

        # 获取数据
        data = request.data

        # 验证数据
        # ser = BaseSerializer(data=data)
        ser = self.get_serializer(data=data)
        ser.is_valis()

        # 保存数据
        ser.save()
        # 返回结果
        return ser.data
